/*
 *  Copyright (C) 2022  贺龙宇
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef SELECTDEV
#define SELECTDEV
#include<unistd.h>
#include<fcntl.h>
#include<termio.h>
#include<cstdio>
#include<string>
#include<ctime>

#include "../Serial/SerialPort.h"
#include "../SerialPort/Protocol.h"
#include "../Log/log.h"
#include "../define.h"

#define SELECTDEV_TFLUNA 0
#define SELECTDEV_MCU    1

/*该模块最初目的是当有两个以上串口共存时用于区别两个不同的串口而制定的*/
/*目前由于并不采用激光雷达进行测距，且取消了握手过程，因此这个模块也就没有使用了*/
class SelectDev
{
public:
  	SelectDev();
  	~SelectDev();
  	bool OpenDevice(SerialPort &serial_port,int test_mode);
  	bool TestSerial(const char* port_name,int test_mode);
private:
  	bool IsTFLUNA(SerialPort &serial_port);
 	bool IsMcu(SerialPort &serial_port);
};

extern SelectDev *selectDev;
#endif